Function GetToken(cString As String) As String
'
' get a token from the input line
'
Dim intTemp As Integer
'
intTemp = InStr(cString, " ")
If intTemp > 0 Then
GetToken = Left(cString, intTemp - 1)
Else
GetToken = ""
End If
'
End Function
The comments in the code explain things pretty well. You use the Visual Basic InStr function to locate the first occurrence of a space within the script line, and then use that position to grab a copy of the first word in the line. If you can't find a word, you return an empty string.
Now let's add the three ''setup" values you can use in your scripts: DBCONNECT, DBVERSION and DBQUIET. These three keywords do not actually execute any real actions, but they do set values used by the other action words DBOPEN and DBMAKE.
First, add the code for the DBCONNECT keyword from Listing A.16. This code just accepts the Connect string from the script and saves it to an internal variable.
Listing A.16. Coding the SQLDBConnect method.
Public Sub SQLdbConnect()
'
' set global connect property
'
strConnect = strSQLLine
'
End Sub
Now, add the code from Listing A.17 to handle the DBVERSION keyword.
Listing A.17. Coding the SQLdbVersion subroutine.
Public Sub SQLdbVersion()
'
' set global version value
'